Skip to content

Dune switch [do not merge]#13

Open
UnixJunkie wants to merge 20 commits into
ocaml-community:masterfrom
UnixJunkie:dune_switch
Open

Dune switch [do not merge]#13
UnixJunkie wants to merge 20 commits into
ocaml-community:masterfrom
UnixJunkie:dune_switch

Conversation

@UnixJunkie

Copy link
Copy Markdown
Collaborator

If we do this, then it compiles with dune, but all the tests and examples fail like

File "/home/berenger/src/ocamlscript/tests/./unpack", line 9, characters 0-26:
Error: Unbound module Ocamlscript

Hence the [do not merge].

plus add missing '|' on each first pattern matched
add missing '|' on first pattern matched
add missing '|' character on first pattern matched
renamed:    common.mli -> src/common.mli
renamed:    ocaml.ml -> src/ocaml.ml
renamed:    ocaml.mli -> src/ocaml.mli
renamed:    pipeline.ml -> src/pipeline.ml
renamed:    pipeline.mli -> src/pipeline.mli
renamed:    std.ml -> src/std.ml
renamed:    utils.ml -> src/utils.ml
renamed:    utils.mli -> src/utils.mli
needed to make unused vars explicit
so that dune knows it must be installed
dune requirement, apparently, since from one module we create
both an exe and a library
@UnixJunkie

Copy link
Copy Markdown
Collaborator Author

related to #7

@jrfondren

Copy link
Copy Markdown

the errors are due to META getting installed as an empty file. dune installs the file, but only the Makefile populates it

@jrfondren

Copy link
Copy Markdown

fix: rename META.in to META.ocamlscript.template

since a version's not set anywhere, dune will generate one like v2.0.3-46-gbc58ce8-dirty, but it works.

@UnixJunkie

UnixJunkie commented Dec 13, 2025 via email

Copy link
Copy Markdown
Collaborator Author

@jrfondren

Copy link
Copy Markdown

My commitment to OCaml isn't firm right now, so that's probably a bad idea. What I'd prefer is also a break from the current design:

  1. dune for script configuration instead of Ocaml.packs et al., with camlp4 or ppx and such offloaded to dune in an ephemeral project
  2. configuration in a comment so that ocamlscript tolerates it
#! /usr/bin/env ocamlscript

(* (executable (libraries unix)) *)

let () =
  let file = Sys.argv.(1) in
  try
    Unix.access file [Unix.R_OK];
    print_endline ("file exists: " ^ file)
  with Unix.Unix_error (Unix.ENOENT, _, _) ->
    print_endline ("file doesn't exist: " ^ file)

@jrfondren

jrfondren commented Dec 21, 2025

Copy link
Copy Markdown

@UnixJunkie got any feedback on https://github.com/jrfondren/thin-ocamlscript ?

This loses calc.ml, and the result is

#! /usr/bin/env -S thin-ocamlscript -package unix -linkpkg --

let () =
  if Array.length Sys.argv <> 2 then (
    Printf.printf "usage: %s <file>\n" Sys.argv.(0);
    exit 1);
  let file = Sys.argv.(1) in
  try
    Unix.access file [Unix.R_OK];
    print_endline ("file exists: " ^ file)
  with Unix.Unix_error (Unix.ENOENT, _, _) ->
    print_endline ("file doesn't exist: " ^ file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants